﻿using Microsoft.Data.SqlClient;
using System.Security.Cryptography;
using System.Text;
using HRMSystemShi.Model;
namespace HRMSystemShi._2025
{
    public static class CommonHelper
    {
        public static string GetMD5(string input)
        {
            MD5 md5 = MD5.Create();
            byte[] inputBytes = Encoding.UTF8.GetBytes(input);
            byte[] md5Bytes = md5.ComputeHash(inputBytes);
            StringBuilder sb = new StringBuilder();
            foreach (byte b in md5Bytes)
            {
                sb.Append(b.ToString("x2"));
            }
            return sb.ToString();
        }
        public static void MessageSuccess(string _message)
        {
            MessageBox.Show($"{_message}", "成功提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public static void MessageError(string _message)
        {
            MessageBox.Show($"{_message}","成功提示",MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        public static DialogResult MessageYesOrNo(string _message)
        {
           return MessageBox.Show($"{_message}","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning);
        }
        public static string MessageUserInfomation()
        {
            string isAdmin = LoginUserInfo.GetInstance().IsAdmin ? "管理员" : "";
            return "欢迎您：" +isAdmin+ LoginUserInfo.GetInstance().RealName+"    登陆时间："+DateTime.Now;
        }
    }
}
